
Texture alphaTexture;

sampler2D colorMapSampler : register(S0);

sampler alphaMaskSampler = sampler_state
{
    Texture = <alphaTexture>;
};

float4 PixelShaderFunction(float4 position : POSITION0, float2 texCoord : TEXCOORD0) : COLOR0
{
    float alpha = clamp(tex2D(alphaMaskSampler, texCoord).r, 0.0f, 1.0f);
    float4 color = tex2D(colorMapSampler, texCoord);
    return float4(color.r * alpha, color.g * alpha, color.b * alpha, 1.0f);
}

technique Technique1
{
    pass Pass1
    {
        PixelShader = compile ps_2_0 PixelShaderFunction();
    }
}